<?php
/**
 * 
 * Author: wxl
 * Date: 2016/4/25
 * Time: 09:44
 * intro:充电宝充值service
 */

class rechargeService extends BaseService
{
    public function _initialize()
    {
        parent::_initialize();

        $this->mLog = D('ChargingLog');
    }

    /**
     * 充电保相关记录异步加载记录
     * @param $condition 记录筛选条件
     * @param $page 每次加载的记录数目
     * @param $model
     * @return bool
     */
    public function setRecordParam($condition,$page,$model) {
        $limit = $page;
        $count = isset($_REQUEST['count']) ? intval($_REQUEST['count']) : 1;
        if($count == 1) {
            $limit = "0,".$page;
        } else {
            $limit = ($count - 1) * $limit + 1 ."," .$page;
        }

        $chargingRecordCount = $model->getCount($condition);
        if($chargingRecordCount <= $page) {
            $block = 0;
        } else {
            $a = ceil($chargingRecordCount / $page);
            $block = $a - $count;
        }

        $data['count'] = $count;
        $data['block'] = $block;
        $data['limit'] = $limit;

        if($data) {
            return $data;
        }
        return false;
    }



}